package com.level2app.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.QuickViewHolder;
import com.level2app.R;
import com.level2app.bean.HomeCategoriesBean;

/**
 * Created by S
 * time 2024/8/16
 */
public class HomeCategoriesAdapter extends BaseQuickAdapter<HomeCategoriesBean, QuickViewHolder> {
    private int[] imgData = new int[]{R.mipmap.icon_cate_hotel_resort, R.mipmap.icon_cate_grand_open,
            R.mipmap.icon_cate_live_music, R.mipmap.icon_cate_tourism};
    public HomeCategoriesAdapter() {
    }

    @NonNull
    @Override
    protected QuickViewHolder onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new QuickViewHolder(R.layout.item_home_categories, viewGroup);
    }

    @Override
    protected void onBindViewHolder(@NonNull QuickViewHolder holder, int i, @Nullable HomeCategoriesBean bean) {
        if (bean == null) return;
        holder.setText(R.id.contentTv, bean.getName());
        LinearLayout layout = holder.getView(R.id.itemLl);
        if (bean.isChoose()) {
            layout.setBackgroundResource(R.drawable.shape_ffffff_12dp);
        } else {
            layout.setBackground(null);
        }
        holder.setImageResource(R.id.iconIv, imgData[i]);
    }
}